//创建追杀飞机 by k1

_tag = _this; //selectRandom (call A3E_fnc_GetPlayers - Escape_Players_enemy)
_pos = [_tag, 1500, 5000,1,1] call BIS_fnc_findSafePos;
_arr = [_pos, 0, (selectRandom a3e_arr_CASplane), A3E_VAR_Side_Opfor] call BIS_fnc_spawnVehicle;
_veh = _arr select 0;
_crew = _arr select 1;
_grp = _arr select 2;
Escape_air_killer pushback _veh;

{[_x,.8] call Escape_setSkills} forEach _crew;

//systemchat format["创建追杀飞机. 追杀载具总计%1架", {alive _x} count Escape_air_killer];

_h = round(random 800); //600
if (_h < 110) then {_h = 110};
_veh flyInHeight _h;

_veh doMove (getPos _tag);
_grp setSpeedMode (selectRandom ["LIMITED","NORMAL","FULL"]);

_veh reveal _tag;
_veh commandTarget _tag;
_veh commandFire _tag;

_veh spawn {
	_t = time + 600; //
	waitUntil {sleep 3; (!alive _this || {time > _t && {{_this distance2D _x < 999} count (call A3E_fnc_GetPlayers - Escape_Players_enemy) == 0}})};
	_this setDamage 1;
};

[_veh, _grp] spawn {
	params ["_veh", "_grp"];
	waitUntil {
		_pos = getPosASL _veh;
		sleep ([10,30] call BIS_fnc_randomInt); //
		if (!alive _veh || {!alive (driver _veh)} || {(getpos _veh select 2) < 1}) exitWith {true};
		_tag = _veh call Escape_minDisUnit;
		if (alive _tag) then {
			_dir = _veh getDir _tag;
			_pos = if(([0,1] call BIS_fnc_randomInt) == 1)then[{_tag getPos [([500,999] call BIS_fnc_randomInt), _dir]},{_tag getPos [([-50,-100] call BIS_fnc_randomInt), _dir]}];
			_veh doMove _pos;
			_h = round(random 800); //600
			if (_h < 110) then {_h = 110};
			_veh flyInHeight _h;
			_grp setSpeedMode (selectRandom ["LIMITED","NORMAL","FULL"]);
			_veh reveal _tag;
			_veh commandTarget _tag;
			_veh commandFire _tag;
			if (_veh getVariable ["DB_laser", true] && {_tag getVariable ["DB_laser_locking", true]} && {random 100 < 30} && {_tag getVariable ["FAR_isUnconscious", 0] == 0} && {DR_laser_count < 3}) then {
				_laser = [_veh, _tag] call DR_spawn_laser;
				if (DR_laser_count < 0) then {DR_laser_count = 0};
				DR_laser_count = DR_laser_count + 1;
				_veh setVariable ["DB_laser", false];
				_tag setVariable ["DB_laser_locking", false];
				//systemchat format["创建激光指示. 总计%1条", DR_laser_count];
				[_veh, _tag, _laser] spawn {
					params ["_veh", "_tag", "_laser"];
					_t = time + (30+random 90);
					waitUntil {
						if (!alive _veh || {!alive _tag} || {_tag getVariable ["FAR_isUnconscious", 0] == 1} || {time > _t}) exitWith {
							_veh setVariable ["DB_laser", true];
							_tag setVariable ["DB_laser_locking", true];
							DR_laser_count = DR_laser_count - 1;
							deleteVehicle _laser;
							true
						};
						_veh2 = vehicle _tag;
						_pos = visiblePosition _veh2;
						if ((_pos select 0)+(_pos select 1) != 0) then {
							if(surfaceIsWater _pos)then{_pos = visiblePositionASL _veh2};
							[_laser, _pos] call DR_fn_setPosAGLS;
							_veh reveal _laser;
						};
						sleep .1;
						false
					};
				};
			};
		};
		false
	};
};
sleep 2;





